package org.poem.client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;

public class TimeClient {

  public static final String address = "127.0.0.1";

  public static void main(String... args) {
    int port = 8080;
    Socket socket = null;
    BufferedReader reader = null;
    PrintStream out = null;

    try {
      socket = new Socket(address, port);
      reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
      out = new PrintStream(socket.getOutputStream(), true);
      out.println("QUERY TIME ORDER");
      System.out.println("Send order 2 service successd.");
      String rep = reader.readLine();
      System.out.println("Now is :" + rep);
    } catch (IOException e) {
    } finally {
      if (out != null) {
        out.close();
        out = null;
      }
      if (reader != null) {
        try {
          reader.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      reader = null;
      if (socket != null) {
        try {
          socket.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      socket = null;
    }
  }
}
